#pragma once
#include "LinkedList.h"
#include <iostream>
#include "FileHandler.h"
#include "stdio.h"





class Object
{
public:
	virtual void Load( FILE* a_File ){}
	virtual void Save( FILE* a_File ){}
};

//#pragma region "Op Code to String" Functions
//
///// <summary>
///// Gets the string representative of a comparison op code
///// </summary>
///// <param name="opCode">Op code</param>
///// <returns>String version of the op code</returns>
//char* ReturnOp(int opCode)
//{
//	switch (opCode)
//	{
//	case 0:
//		return "==";
//	case 1:
//		return ">";
//	case 2:
//		return ">=";
//	case 3:
//		return "<";
//	case 4:
//		return "<=";
//	case 10:
//		return "!=";
//	default:
//		return "[Invalid OpCode]";
//	}
//}
//
///// <summary>
///// Gets the string representative of a comparison op code
///// </summary>
///// <param name="opCode">Op code</param>
///// <returns>String version of the op code</returns>
//char* ReturnChangeOp(int opCode)
//{
//	switch (opCode)
//	{
//	case 5:
//		return "=";
//	case 6:
//		return "+=";
//	case 7:
//		return "-=";
//	default:
//		return "[Invalid OpCode]";
//	}
//}
//
///// <summary>
///// Gets the string representative of an ability op code
///// </summary>
///// <param name="opCode">Op code</param>
///// <returns>String version of the op code</returns>
//char* ReturnAbility(int ability)
//{
//	switch (ability)
//	{
//	case 0:
//		return "Level";
//	case 1:
//		return "Attack Power";
//	case 2:
//		return "Defence";
//	case 3:
//		return "Magical Defence";
//	case 4:
//		return "HP";
//	case 5:
//		return "Charm";
//	default:
//		return "[Invalid Ability]";
//	}
//}
//
///// <summary>
///// Gets the string representative of a economy variable op code
///// </summary>
///// <param name="opCode">Op code</param>
///// <returns>String version of the op code</returns>
//char* ReturnEconomyVariable(int variableIndex)
//{
//	switch (variableIndex)
//	{
//	case 0:
//		return "Town Rate";
//	case 1:
//		return "Town Population";
//	case 2:
//		return "Town Development";
//	case 3:
//		return "Town Item 1";
//	case 4:
//		return "Town Item 2";
//	case 5:
//		return "Town Item 3";
//	case 6:
//		return "Town Item 4";
//	case 7:
//		return "Town Item 5";
//	case 8:
//		return "Town Item 6";
//	case 9:
//		return "Town Item 7";
//	case 10:
//		return "Town Item 8";
//	case 11:
//		return "Town Item 9";
//	case 12:
//		return "Town Item 10";
//	case 13:
//		return "Item Rate 1";
//	case 14:
//		return "Item Rate 2";
//	case 15:
//		return "Item Rate 3";
//	case 16:
//		return "Item Rate 4";
//	case 17:
//		return "Item Rate 5";
//	case 18:
//		return "Item Rate 6";
//	case 19:
//		return "Item Rate 7";
//	case 20:
//		return "Item Rate 8";
//	case 21:
//		return "Item Rate 9";
//	case 22:
//		return "Item Rate 10";
//	default:
//		return "[Invalid Variable]";
//	}
//}
//
///// <summary>
///// Gets the string representative of an weekday op code
///// </summary>
///// <param name="opCode">Op code</param>
///// <returns>String version of the op code</returns>
//char* ReturnWeekday(int day)
//{
//	switch (day)
//	{
//	case 0:
//		return "Monday";
//	case 1:
//		return "Tuesday";
//	case 2:
//		return "Wednesday";
//	case 3:
//		return "Thursday";
//	case 4:
//		return "Friday";
//	case 5:
//		return "Saturday";
//	case 6:
//		return "Sunday";
//	default:
//		return "[Invalid Weekday]";
//	}
//}
//
//#pragma endregion

const int CONDITION = 0x04000000;
const int ACTION = 0x0B000000;

/// <summary>
/// Condition Enumeration
/// </summary>
enum ConditionType
{
	CONDITION0  = 0x000000001 | CONDITION,
	CONDITION1  = 0x000000002 | CONDITION,
	CONDITION2  = 0x000000003 | CONDITION,
	CONDITION3  = 0x000000004 | CONDITION,
	CONDITION4  = 0x000000005 | CONDITION,
	CONDITION5  = 0x000000006 | CONDITION,
	CONDITION6  = 0x000000007 | CONDITION,
	CONDITION7  = 0x000000008 | CONDITION,
	CONDITION8  = 0x000000009 | CONDITION,
	CONDITION9  = 0x00000000A | CONDITION,
	CONDITION10 = 0x00000000B | CONDITION,
	CONDITION11 = 0x00000000C | CONDITION,
	CONDITION12 = 0x00000000D | CONDITION,
	CONDITION13 = 0x00000000E | CONDITION,
	CONDITION14 = 0x00000000F | CONDITION,
	CONDITION15 = 0x000000010 | CONDITION,
	CONDITION16 = 0x000000011 | CONDITION,
	CONDITION17 = 0x000000012 | CONDITION,
	CONDITION18 = 0x000000013 | CONDITION,
	CONDITION19 = 0x000000014 | CONDITION,
	CONDITION20 = 0x000000015 | CONDITION,
	CONDITION21 = 0x000000016 | CONDITION,
	CONDITION22 = 0x000000017 | CONDITION,
	CONDITION23 = 0x000000018 | CONDITION,
	CONDITION24 = 0x000000019 | CONDITION,
	CONDITION25 = 0x00000001A | CONDITION,
	CONDITION26 = 0x00000001B | CONDITION,
	CONDITION27 = 0x00000001C | CONDITION,
	CONDITION28 = 0x00000001D | CONDITION,
	CONDITION29 = 0x00000001E | CONDITION
};

#pragma region Conditions
/// <summary>
/// Fighting or Idle
/// </summary>
class Condition0 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_FightOrDelay, sizeof( m_FightOrDelay ) + 3, 1, a_File );
	}
	void Save( FILE* a_File )
	{
		//Writing a byte, from char missing 3 bits.
		fwrite( &m_FightOrDelay, sizeof( m_FightOrDelay ) + 3, 1, a_File );
		
	}
	unsigned char m_FightOrDelay;
};

/// <summary>
/// Check Damage
/// </summary> 
class Condition1 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_Damage, sizeof( m_Damage ), 1, a_File );
		fread( &m_ReceiveOrGive, sizeof( m_ReceiveOrGive ) + 3, 1, a_File );
	}
	void Save( FILE* a_File )
	{
		fwrite( &m_Damage, sizeof( m_Damage ), 1, a_File );
		fwrite( &m_ReceiveOrGive, sizeof( m_ReceiveOrGive ) + 3, 1, a_File );
	}
	int m_Damage;
	unsigned char m_ReceiveOrGive;
};

/// <summary>
/// Select Nearest Enemy/Ally (Old)
/// </summary>
class Condition2 : public Object
{
public:
	void Load( FILE* a_File )
	{
		int skip;
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fread( &m_IsAllied, sizeof( m_IsAllied ), 1, a_File );
		fread( &skip, 1, 1, a_File ); //skiping one bit
		fread( &m_LevelMin, sizeof( m_LevelMin ), 1, a_File );
		fread( &m_LevelMax, sizeof( m_LevelMax ), 1, a_File );
		fread( &m_CharNumber, sizeof( m_CharNumber ), 1, a_File );
	}

	void Save( FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fwrite( &m_IsAllied, sizeof( m_IsAllied ) + 1, 1, a_File );
		fwrite( &m_LevelMin, sizeof( m_LevelMin ), 1, a_File );
		fwrite( &m_LevelMax, sizeof( m_LevelMax ), 1, a_File );
		fwrite( &m_CharNumber, sizeof( m_CharNumber ), 1, a_File );
	}

	int m_Distance;
	unsigned char m_IsAllied;
	short m_LevelMin;
	short m_LevelMax;
	unsigned short m_CharNumber;
};

/// <summary>
/// Check Move Distance
/// </summary>
class Condition3 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File);
		bool check = true;
	}
	void Save(  FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
	}
	int m_Distance;
};

/// <summary>
/// Check Target Distance
/// </summary>
class Condition4 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fread( &m_MoreOrLess, sizeof( m_MoreOrLess ) + 3, 1, a_File );
	}

	void Save( FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fwrite( &m_MoreOrLess, sizeof( m_MoreOrLess ) + 3, 1, a_File );
	}
	int m_Distance;
	unsigned char m_MoreOrLess;
};

/// <summary>
/// Check Target Ability
/// </summary>
class Condition5 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_AbilityType, sizeof( m_AbilityType ) + 3, 1, a_File );
		fread( &m_Value, sizeof( m_Value ), 1, a_File );
		fread( &m_MoreOrLess, sizeof( m_MoreOrLess ) + 3, 1, a_File );
	}

	void Save( FILE* a_File )
	{
		fwrite( &m_AbilityType, sizeof( m_AbilityType ) + 3, 1, a_File );
		fwrite( &m_Value, sizeof( m_Value ), 1, a_File );
		fwrite( &m_MoreOrLess, sizeof( m_MoreOrLess ) + 3, 1, a_File );
	}
	unsigned char m_AbilityType;
	int m_Value;
	unsigned char m_MoreOrLess;

};

/// <summary>
/// Check HP Percent
/// </summary>
class Condition6: public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_HP, sizeof( m_HP ), 1, a_File );
		fread( &m_MoreOrLess, sizeof( m_MoreOrLess ) + 3, 1, a_File );
	}

	void Save( FILE* a_File )
	{
		fwrite( &m_HP, sizeof( m_HP ), 1, a_File );
		fwrite( &m_MoreOrLess, sizeof( m_MoreOrLess ) + 3, 1, a_File );
	}

	int m_HP;
	unsigned char m_MoreOrLess;
};

/// <summary>
/// Random Chance
/// </summary>
class Condition7: public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_Percentage, sizeof( m_Percentage ), 1, a_File );
	}
	void Save( FILE* a_File )
	{
		fwrite( &m_Percentage, sizeof( m_Percentage ), 1, a_File );
	}
	int m_Percentage;
};

/// <summary>
/// Select Nearest Enemy/Ally ("Find" and "Near" Char)
/// </summary>
class Condition8: public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fread( &m_LevelMin, sizeof( m_LevelMin ), 1, a_File );
		fread( &m_LevelMax, sizeof( m_LevelMax ), 1, a_File );
		fread( &m_IsAllied, sizeof( m_IsAllied ) + 3, 1, a_File );
	}

	void Save( FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fwrite( &m_LevelMin, sizeof( m_LevelMin ), 1, a_File );
		fwrite( &m_LevelMax, sizeof( m_LevelMax ), 1, a_File );
		fwrite( &m_IsAllied, sizeof( m_IsAllied ) + 3, 1, a_File );
	}
	int m_Distance;
	short m_LevelMin;
	short m_LevelMax;
	unsigned char m_IsAllied;
};

/// <summary>
/// Has Target
/// </summary>
class Condition9 : public Object
{
public:
	void Load( FILE* a_File )
	{
		//No loading
	}
	
	void Save(  FILE* a_File )
	{
		//No saving
	}

};

/// <summary>
/// Compare Destination and Target Ability
/// </summary>
class Condition10 : public Object
{
	void Load( FILE* a_File )
	{
		//Loading
		fread( &m_AbilityType, sizeof( m_AbilityType ), 1, a_File );
		fread( &m_MoreOrLess, sizeof( m_MoreOrLess) + 2, 1, a_File );
	}

	void Save(  FILE* a_File )
	{
		//saving
		fwrite( &m_AbilityType, sizeof( m_AbilityType ), 1, a_File );
		fwrite( &m_MoreOrLess, sizeof( m_MoreOrLess) + 2, 1, a_File );
	}
	unsigned char m_AbilityType;
	unsigned char m_MoreOrLess;
};

/// <summary>
/// Check Destination Ability (Target Must be NULL)
/// </summary>
class Condition11 : public Object
{
	void Load( FILE* a_File )
	{
		//Loading
		fread( &m_AbilityType, sizeof ( m_AbilityType ) + 3, 1, a_File );
		fread( &m_Value, sizeof( m_Value ), 1, a_File );
		fread( &m_MoreOrLess, sizeof( m_MoreOrLess ) + 3, 1, a_File );
	}

	void Save(  FILE* a_File )
	{
		//Saving
		fwrite( &m_AbilityType, sizeof ( m_AbilityType ) + 3, 1, a_File );
		fwrite( &m_Value, sizeof( m_Value ), 1, a_File );
		fwrite( &m_MoreOrLess, sizeof( m_MoreOrLess ) + 3, 1, a_File );
	}

	unsigned char m_AbilityType;
	int m_Value;
	unsigned char m_MoreOrLess;
};

/// <summary>
/// Day or Night
/// </summary>
class Condition12 : public Object
{
	void Load( FILE* a_File )
	{
		//Loading
		fread( &m_When, sizeof( m_When ) + 3, 1, a_File );
	}

	void Save(  FILE* a_File )
	{
		//Saving
		fwrite( &m_When, sizeof( m_When ) + 3, 1, a_File );
	}

	unsigned char m_When;
};

/// <summary>
/// Check Target/Monster Magic Status
/// </summary>
class Condition13 : public Object
{
	void Load( FILE* a_File )
	{
		//Loading
		fread( &m_CheckTarget, sizeof( m_CheckTarget ), 1, a_File );
		fread( &m_StatusType, sizeof( m_StatusType ), 1, a_File );
		fread( &m_Have, sizeof( m_Have ) + 1, 1, a_File );

	}

	void Save(  FILE* a_File )
	{
		//Saving
		fwrite( &m_CheckTarget, sizeof( m_CheckTarget ), 1, a_File );
		fwrite( &m_StatusType, sizeof( m_StatusType ), 1, a_File );
		fwrite( &m_Have, sizeof( m_Have ) + 1, 1, a_File );
	}

	unsigned char m_CheckTarget;
	unsigned char m_StatusType;
	unsigned char m_Have;

};

/// <summary>
/// Check NPC Variable
/// </summary>
class Condition14 : public Object
{
	void Load( FILE* a_File )
	{
		//Loading
		fread( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fread( &m_Value, sizeof( m_Value ), 1, a_File );
		fread( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	}

	void Save(  FILE* a_File )
	{
		//Saving
		fwrite( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fwrite( &m_Value, sizeof( m_Value ), 1, a_File );
		fwrite( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	}
	short m_VariableIndex;
	int m_Value;
	unsigned char m_OpCode;
};

/// <summary>
/// Check World Variable
/// </summary>
class Condition15 : public Object
{
public:
	void Load( FILE* a_File )
	{
		//Loading
		fread( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fread( &m_Value, sizeof( m_Value ), 1, a_File );
		fread( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	}

	void Save(  FILE* a_File )
	{
		//Saving
		fwrite( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fwrite( &m_Value, sizeof( m_Value ), 1, a_File );
		fwrite( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	}
	short m_VariableIndex;
	int m_Value;
	unsigned char m_OpCode;
};

/// <summary>
/// Check Economic Variable
/// </summary>
class Condition16 : public Object
{
	void Load( FILE* a_File )
	{
		//Loading
		fread( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fread( &m_Value, sizeof( m_Value ), 1, a_File );
		fread( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	}

	void Save(  FILE* a_File )
	{
		//Saving
		fwrite( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fwrite( &m_Value, sizeof( m_Value ), 1, a_File );
		fwrite( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	}
	short m_VariableIndex;
	int m_Value;
	unsigned char m_OpCode;
};

/// <summary>
/// Select NPC
/// </summary>
class Condition17 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_NPCID, sizeof( m_NPCID ), 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_NPCID, sizeof( m_NPCID ), 1, a_File );
	};
	int m_NPCID;
};

/// <summary>
/// Check Caller Distance
/// </summary>
class Condition18 : public Object
{
public:
	void Load(  FILE* a_File )
	{
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fread( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	};

	void Save(  FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fwrite( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	};

	int m_Distance;
	unsigned char m_OpCode;
};

/// <summary>
/// Check Caller Distance
/// </summary>
class Condition19 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_Time, sizeof( m_Time ), 1, a_File );
		fread( &m_EndTime, sizeof( m_EndTime ), 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Time, sizeof( m_Time ), 1, a_File );
		fwrite( &m_EndTime, sizeof( m_EndTime ), 1, a_File );
	};
	unsigned int m_Time;
	unsigned int m_EndTime;
};

/// <summary>
/// Check Source Character Ability
/// </summary>
class Condition20 : public Object
{
public:
	void Load( FILE* a_File )
	{
		//Loading
		fread( &m_AbilityType, sizeof ( m_AbilityType ) + 3, 1, a_File );
		fread( &m_Value, sizeof( m_Value ), 1, a_File );
		fread( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	}

	void Save(  FILE* a_File )
	{
		//Saving
		fwrite( &m_AbilityType, sizeof ( m_AbilityType ) + 3, 1, a_File );
		fwrite( &m_Value, sizeof( m_Value ), 1, a_File );
		fwrite( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	}
	unsigned char m_AbilityType;
	int m_Value;
	unsigned char m_OpCode;
};

/// <summary>
/// Has Caller
/// </summary>
class Condition21 : public Object
{
public:
	void Load( FILE* a_File )
	{
		//nothing
	};

	void Save( FILE* a_File )
	{
		//nothing
	};
};

/// <summary>
/// Caller Has Target
/// </summary>
class Condition22 : public Object
{
public:
	void Load( FILE* a_File )
	{
		//nothing
	};

	void Save( FILE* a_File )
	{
		//nothing
	};
};

/// <summary>
/// Check World Time
/// </summary>
class Condition23 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_Time, sizeof( m_Time ), 1, a_File );
		fread( &m_EndTime, sizeof( m_EndTime ), 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Time, sizeof( m_Time ), 1, a_File );
		fwrite( &m_EndTime, sizeof( m_EndTime ), 1, a_File );
	};
	unsigned int m_Time;
	unsigned int m_EndTime;
};

/// <summary>
/// Check Month and Day Time (Week Day Optional)
/// </summary>
class Condition24 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_Date, sizeof( m_Date ), 1, a_File );
		fread( &m_Hour1, sizeof( m_Hour1 ), 1, a_File );
		fread( &m_Minute1, sizeof( m_Minute1 ), 1, a_File );
		fread( &m_Hour2, sizeof( m_Hour2 ), 1, a_File );
		fread( &m_Minute2, sizeof( m_Minute2 ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Date, sizeof( m_Date ), 1, a_File );
		fwrite( &m_Hour1, sizeof( m_Hour1 ), 1, a_File );
		fwrite( &m_Minute1, sizeof( m_Minute1 ), 1, a_File );
		fwrite( &m_Hour2, sizeof( m_Hour2 ), 1, a_File );
		fwrite( &m_Minute2, sizeof( m_Minute2 ) + 3, 1, a_File );
	};
	unsigned char m_Date;
	unsigned char m_Hour1;
	unsigned char m_Minute1;
	unsigned char m_Hour2;
	unsigned char m_Minute2;
};

/// <summary>
/// Check Weekday Time
/// </summary>
class Condition25 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_WeekDay, sizeof( m_WeekDay ), 1, a_File );
		fread( &m_Hour1, sizeof( m_Hour1 ), 1, a_File );
		fread( &m_Minute1, sizeof( m_Minute1 ), 1, a_File );
		fread( &m_Hour2, sizeof( m_Hour2 ), 1, a_File );
		fread( &m_Minute2, sizeof( m_Minute2 ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_WeekDay, sizeof( m_WeekDay ), 1, a_File );
		fwrite( &m_Hour1, sizeof( m_Hour1 ), 1, a_File );
		fwrite( &m_Minute1, sizeof( m_Minute1 ), 1, a_File );
		fwrite( &m_Hour2, sizeof( m_Hour2 ), 1, a_File );
		fwrite( &m_Minute2, sizeof( m_Minute2 ) + 3, 1, a_File );
	};
	unsigned char m_WeekDay;
	unsigned char m_Hour1;
	unsigned char m_Minute1;
	unsigned char m_Hour2;
	unsigned char m_Minute2;
};

/// <summary>
/// Check Channel Number
/// </summary>
class Condition26 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_X, sizeof( m_X ), 1, a_File );
		fread( &m_Y, sizeof( m_Y ), 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_X, sizeof( m_X ), 1, a_File );
		fwrite( &m_Y, sizeof( m_Y ), 1, a_File );
	};
	unsigned short m_X;
	unsigned short m_Y;
};

/// <summary>
/// Find Closest Character by Minimum Distance and Level
/// </summary>
class Condition27 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fread( &m_IsAllied, sizeof( m_IsAllied ) + 1, 1, a_File );
		fread( &m_MinLevel, sizeof( m_MinLevel ), 1, a_File );
		fread( &m_MaxLevel, sizeof( m_MaxLevel ), 1, a_File );
		fread( &m_CharacterNumber, sizeof( m_CharacterNumber ), 1, a_File );
		fread( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fwrite( &m_IsAllied, sizeof( m_IsAllied ) + 1, 1, a_File );
		fwrite( &m_MinLevel, sizeof( m_MinLevel ), 1, a_File );
		fwrite( &m_MaxLevel, sizeof( m_MaxLevel ), 1, a_File );
		fwrite( &m_CharacterNumber, sizeof( m_CharacterNumber ), 1, a_File );
		fwrite( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	};
	int m_Distance;
	unsigned char m_IsAllied;
	short m_MinLevel;
	short m_MaxLevel;
	short m_CharacterNumber;
	unsigned char m_OpCode;
};

/// <summary>
/// Check AI Variable
/// </summary>
class Condition28 : public Object
{
public:
	void Load( FILE* a_File )
	{
		//Loading
		fread( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fread( &m_Value, sizeof( m_Value ), 1, a_File );
		fread( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	}

	void Save(  FILE* a_File )
	{
		//Saving
		fwrite( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fwrite( &m_Value, sizeof( m_Value ), 1, a_File );
		fwrite( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	}
	short m_VariableIndex;
	int m_Value;
	unsigned char m_OpCode;
};

/// <summary>
/// Is Target Clan Master
/// </summary>
class Condition29 : public Object
{
public:
	void Load( FILE* a_File )
	{
		fread( &m_TargetType, sizeof( m_TargetType ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_TargetType, sizeof( m_TargetType ) + 3, 1, a_File );
	};
	unsigned char m_TargetType;
};
#pragma endregion Conditions

class Condition
{
public:
	Condition();
	~Condition();
	void Load( FILE* a_File );	
	void Save( FILE* a_File );

	int m_Size;
	int m_Command;
	Object* m_Value;
};

/// <summary>
/// Action Enumeration
/// </summary>
enum ActionType
{
	ACTION0  = 0x000000001 | ACTION,
	ACTION1  = 0x000000002 | ACTION,
	ACTION2  = 0x000000003 | ACTION,
	ACTION3  = 0x000000004 | ACTION,
	ACTION4  = 0x000000005 | ACTION,
	ACTION5  = 0x000000006 | ACTION,
	ACTION6  = 0x000000007 | ACTION,
	ACTION7  = 0x000000008 | ACTION,
	ACTION8  = 0x000000009 | ACTION,
	ACTION9  = 0x00000000A | ACTION,
	ACTION10 = 0x00000000B | ACTION,
	ACTION11 = 0x00000000C | ACTION,
	ACTION12 = 0x00000000D | ACTION,
	ACTION13 = 0x00000000E | ACTION,
	ACTION14 = 0x00000000F | ACTION,
	ACTION15 = 0x000000010 | ACTION,
	ACTION16 = 0x000000011 | ACTION,
	ACTION17 = 0x000000012 | ACTION,
	ACTION18 = 0x000000013 | ACTION,
	ACTION19 = 0x000000014 | ACTION,
	ACTION20 = 0x000000015 | ACTION,
	ACTION21 = 0x000000016 | ACTION,
	ACTION22 = 0x000000017 | ACTION,
	ACTION23 = 0x000000018 | ACTION,
	ACTION24 = 0x000000019 | ACTION,
	ACTION25 = 0x00000001A | ACTION,
	ACTION26 = 0x00000001B | ACTION,
	ACTION27 = 0x00000001C | ACTION,
	ACTION28 = 0x00000001D | ACTION,
	ACTION29 = 0x00000001E | ACTION,
	ACTION30 = 0x00000001F | ACTION,
	ACTION31 = 0x000000020 | ACTION,
	ACTION32 = 0x000000021 | ACTION,
	ACTION33 = 0x000000022 | ACTION,
	ACTION34 = 0x000000023 | ACTION,
	ACTION35 = 0x000000024 | ACTION,
	ACTION36 = 0x000000025 | ACTION,
	ACTION37 = 0x000000026 | ACTION,
};

#pragma region Actions
/// <summary>
/// Stop All Actions
/// </summary>
class Action0 : public Object
{
	void Load( FILE* a_File )
	{
		//Nothing to do
	};

	void Save( FILE* a_File )
	{
		//Nothing to do
		int check = 0;
	};
};

/// <summary>
/// Do Emotion
/// </summary>
class Action1 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Action, sizeof( m_Action ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Action, sizeof( m_Action ) + 3, 1, a_File );
	};

	unsigned char m_Action;
};

/// <summary>
/// Say LTB String (Old)
/// </summary>
class Action2Old : public Object
{
	void Load( FILE* a_File )
	{
		//?
		fread( &m_Message, 4, 1, a_File  );
		bool check = true;
	};

	void Save( FILE* a_File )
	{
		//?
		fwrite( &m_Message, 4, 1, a_File );
		int check = 0;
	};
	
	char m_Message[255];
};

/// <summary>
/// Say LTB String
/// </summary>
class Action2 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_StringID, sizeof( m_StringID ), 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_StringID, sizeof( m_StringID ), 1, a_File );
	};

	int m_StringID;
};

/// <summary>
/// Move Random (Position)
/// </summary>
class Action3 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fread( &m_Speed, sizeof( m_Speed ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fwrite( &m_Speed, sizeof( m_Speed ) + 3, 1, a_File );
	};

	int m_Distance;
	unsigned char m_Speed;
};

/// <summary>
/// Move Random (Spawn Position)
/// </summary>
class Action4 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fread( &m_Speed, sizeof( m_Speed ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fwrite( &m_Speed, sizeof( m_Speed ) + 3, 1, a_File );
	};

	int m_Distance;
	unsigned char m_Speed;
};

/// <summary>
/// Move Random (200 of "Find" Character)
/// </summary>
class Action5 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Speed, sizeof( m_Speed ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Speed, sizeof( m_Speed ) + 3, 1, a_File );
	};

	unsigned char m_Speed;
};

/// <summary>
/// Move To Nearby (Ability)
/// </summary>
class Action6 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fread( &m_AbilityType, sizeof( m_AbilityType ), 1, a_File );
		fread( &m_MoreOrLess, sizeof( m_MoreOrLess ) + 2, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fwrite( &m_AbilityType, sizeof( m_AbilityType ), 1, a_File );
		fwrite( &m_MoreOrLess, sizeof( m_MoreOrLess ) + 2, 1, a_File );
	};

	int m_Distance;
	unsigned char m_AbilityType;
	unsigned char m_MoreOrLess;
};

/// <summary>
/// Special Attack
/// </summary>
class Action7 : public Object
{
	void Load( FILE* a_File )
	{
		//nothing to do
		fread( &m_Test, sizeof( m_Test ), 1, a_File );
		int check = 0;
	};

	void Save( FILE* a_File )
	{
		//nothing to do
		fwrite( &m_Test, sizeof( m_Test ), 1, a_File );
	};

	unsigned char m_Test;
};

/// <summary>
/// Move Percentage Away From Target
/// </summary>
class Action8 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fread( &m_Speed, sizeof( m_Speed ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fwrite( &m_Speed, sizeof( m_Speed ) + 3, 1, a_File );
	};

	int m_Distance;
	unsigned char m_Speed;	
};

/// <summary>
/// Transform into Monster
/// </summary
class Action9 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Monster, sizeof( m_Monster ) + 2, 1 , a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Monster, sizeof( m_Monster ) + 2, 1, a_File );
	};

	unsigned short m_Monster;
};

/// <summary>
/// Spawn Monster
/// </summary>
class Action10 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Monster, sizeof( m_Monster ) + 2, 1 , a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Monster, sizeof( m_Monster ) + 2, 1, a_File );
	};

	unsigned short m_Monster;
};

/// <summary>
/// Attack Target (Number of Monsters within Distance)
/// </summary>
class Action11 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Distance, sizeof( m_Distance ), 1 , a_File );
		fread( &m_NumberOfMonsters, sizeof( m_NumberOfMonsters ), 1 , a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1 , a_File );
		fwrite( &m_NumberOfMonsters, sizeof( m_NumberOfMonsters ), 1 , a_File );
	};
	
	int m_Distance;
	int m_NumberOfMonsters;
};

/// <summary>
/// Attack "Near" Character
/// </summary>
class Action12 : public Object
{
	void Load( FILE* a_File )
	{
		//Nothing to do
	};

	void Save( FILE* a_File )
	{
		//Nothing to do
	};
};

/// <summary>
/// Attack "Find" Character
/// </summary>
class Action13 : public Object
{
	void Load( FILE* a_File )
	{
		//Nothing to do
	};

	void Save( FILE* a_File )
	{
		//Nothing to do
	};
};

/// <summary>
/// attack target character (one ally within distance)
/// </summary>
class Action14 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
	};

	int m_Distance;
};

/// <summary>
/// Attack Target
/// </summary>
class Action15 : public Object
{
	void Load( FILE* a_File )
	{
		//Nothing to do
	};

	void Save( FILE* a_File )
	{
		//Nothing to do
	};
};

/// <summary>
/// Run Away
/// </summary>
class Action16 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
	};

	int m_Distance;
};

/// <summary>
/// Drop Random Item
/// </summary>
class Action17 : public Object
{
	void Load( FILE* a_File )
	{
	
		fread( &Item1, sizeof( Item1 ), 1, a_File );
		fread( &Item2, sizeof( Item2 ), 1, a_File );
		fread( &Item3, sizeof( Item3 ), 1, a_File );
		fread( &Item4, sizeof( Item4 ), 1, a_File );
		fread( &Item5, sizeof( Item5 ), 1, a_File );
		fread( &m_Owner, sizeof( m_Owner ) + 1, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &Item1, sizeof( Item1 ), 1, a_File );
		fwrite( &Item2, sizeof( Item2 ), 1, a_File );
		fwrite( &Item3, sizeof( Item3 ), 1, a_File );
		fwrite( &Item4, sizeof( Item4 ), 1, a_File );
		fwrite( &Item5, sizeof( Item5 ), 1, a_File );
		fwrite( &m_Owner, sizeof( m_Owner ) + 1, 1, a_File );
	};
	short Item1;
	short Item2;
	short Item3;
	short Item4;
	short Item5;
	unsigned char m_Owner;
};



/// <summary>
/// Attack Target (Amount of Monsters Within Distance)
/// </summary>
class Action18 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Monster, sizeof( m_Monster ), 1, a_File );
		fread( &m_Amount, sizeof( m_Amount ), 1, a_File );
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Monster, sizeof( m_Monster ), 1, a_File );
		fwrite( &m_Amount, sizeof( m_Amount ), 1, a_File );
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
	};

	unsigned short m_Monster;
	unsigned short m_Amount;
	int m_Distance;
};

/// <summary>
/// Attack "Near" Character
/// </summary>
class Action19 : public Object
{
	void Load( FILE* a_File )
	{
		//Nothing to do
	};

	void Save( FILE* a_File )
	{
		//Nothing to do
	};
};

/// <summary>
/// Spawn Monster at Position
/// </summary>
class Action20 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Monster, sizeof( m_Monster ), 1, a_File );
		fread( &m_Position, sizeof( m_Position ) + 1, 1, a_File );
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Monster, sizeof( m_Monster ), 1, a_File );
		fwrite( &m_Position, sizeof( m_Position ) + 1, 1, a_File );
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
	};

	unsigned short m_Monster;
	unsigned char m_Position;
	int m_Distance;
};

/// <summary>
/// Blank
/// </summary>
class Action21 : public Object
{
	void Load( FILE* a_File )
	{
		//Nothing to do here
	};

	void Save( FILE* a_File )
	{
		//Nothing to do here
	};
};

/// <summary>
/// Blank
/// </summary>
class Action22 : public Object
{
	void Load( FILE* a_File )
	{
		//Nothing to do here
	};

	void Save( FILE* a_File )
	{
		//Nothing to do here
	};
};

/// <summary>
/// Commit Suicide
/// </summary>
class Action23 : public Object
{
	void Load( FILE* a_File )
	{
		//Nothing to do here
	};

	void Save( FILE* a_File )
	{
		//Nothing to do here
	};
};

/// <summary>
/// Perform Skill
/// </summary>
class Action24 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Target, sizeof( m_Target ) + 1, 1, a_File );
		fread( &m_Skill, sizeof( m_Skill ), 1, a_File );
		fread( &m_Motion, sizeof( m_Motion ) + 2, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Target, sizeof( m_Target ) + 1, 1, a_File );
		fwrite( &m_Skill, sizeof( m_Skill ), 1, a_File );
		fwrite( &m_Motion, sizeof( m_Motion ) + 2, 1, a_File );
	};

	unsigned char m_Target;
	unsigned short m_Skill;
	unsigned short m_Motion;
};

/// <summary>
/// Set NPC Variable
/// </summary>
class Action25 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fread( &m_Value, sizeof( m_Value ), 1, a_File );
		fread( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fwrite( &m_Value, sizeof( m_Value ), 1, a_File );
		fwrite( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	};

	short m_VariableIndex;
	int m_Value;
	unsigned char m_OpCode;
};

/// <summary>
/// set world variable
/// </summary>
class Action26 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fread( &m_Value, sizeof( m_Value ), 1, a_File );
		fread( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fwrite( &m_Value, sizeof( m_Value ), 1, a_File );
		fwrite( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	};

	short m_VariableIndex;
	int m_Value;
	unsigned char m_OpCode;
};

/// <summary>
/// Set Economy Variable
/// </summary>
class Action27 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fread( &m_Value, sizeof( m_Value ), 1, a_File );
		fread( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fwrite( &m_Value, sizeof( m_Value ), 1, a_File );
		fwrite( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	};

	short m_VariableIndex;
	int m_Value;
	unsigned char m_OpCode;
};

/// <summary>
/// Shout/Announce LTB String
/// </summary>
class Action28 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_MessageType, sizeof( m_MessageType ) + 3, 1, a_File );
		fread( &m_StringID, sizeof( m_StringID ), 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_MessageType, sizeof( m_MessageType ) + 3, 1, a_File );
		fwrite( &m_StringID, sizeof( m_StringID ), 1, a_File );
	};

	unsigned char m_MessageType;
	int m_StringID;
};

/// <summary>
/// Move Within 20% Distance of Caller
/// </summary>
class Action29 : public Object
{
	void Load( FILE* a_File )
	{
		//nothing to do
	};

	void Save( FILE* a_File )
	{
		//nothing to do
	};
};

/// <summary>
/// Perform Trigger
/// </summary>
class Action30 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Length, sizeof( m_Length ), 1, a_File );
		fread( &m_Trigger, m_Length, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Length, sizeof( m_Length ), 1, a_File );
		fwrite( &m_Trigger, m_Length, 1, a_File );
	};

	char m_Trigger[255];
	short m_Length;	
};

/// <summary>
/// Attack Caller if Not Allied
/// </summary>
class Action31 : public Object
{
	void Load( FILE* a_File )
	{
		//nothing to do
	};

	void Save( FILE* a_File )
	{
		//nothing to do
	};
};

/// <summary>
/// Set PK Flag
/// </summary>
class Action32 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_ZoneID, sizeof( m_ZoneID ), 1, a_File );
		fread( &m_OnOrOff, sizeof( m_OnOrOff ) + 1, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_ZoneID, sizeof( m_ZoneID ), 1, a_File );
		fwrite( &m_OnOrOff, sizeof( m_OnOrOff ) + 1, 1, a_File );
	};
	
	short m_ZoneID;
	unsigned char m_OnOrOff;
};

/// <summary>
/// Set Regeneration System
/// </summary>
class Action33 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_ZoneID, sizeof( m_ZoneID ), 1, a_File );
		fread( &m_OnOrOff, sizeof( m_OnOrOff ) + 1, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_ZoneID, sizeof( m_ZoneID ), 1, a_File );
		fwrite( &m_OnOrOff, sizeof( m_OnOrOff ) + 1, 1, a_File );
	};
	
	short m_ZoneID;
	unsigned char m_OnOrOff;
};

/// <summary>
/// Give Item to Caller
/// </summary
class Action34 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_ItemID, sizeof( m_ItemID ), 1, a_File );
		fread( &m_Count, sizeof( m_Count ), 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_ItemID, sizeof( m_ItemID ), 1, a_File );
		fwrite( &m_Count, sizeof( m_Count ), 1, a_File );
	};

	short m_ItemID;
	short m_Count;
};

/// <summary>
/// Set AI Variable
/// </summary>
class Action35 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fread( &m_Value, sizeof( m_Value ), 1, a_File );
		fread( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_VariableIndex, sizeof( m_VariableIndex ) + 2, 1, a_File );
		fwrite( &m_Value, sizeof( m_Value ), 1, a_File );
		fwrite( &m_OpCode, sizeof( m_OpCode ) + 3, 1, a_File );
	};

	short m_VariableIndex;
	int m_Value;
	unsigned char m_OpCode;
};

/// <summary>
/// Spawn Monster
/// </summary>
class Action36 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Monster, sizeof( m_Monster ), 1, a_File );
		fread( &m_Master, sizeof( m_Master ) + 1, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Monster, sizeof( m_Monster ), 1, a_File );
		fwrite( &m_Master, sizeof( m_Master ) + 1, 1, a_File );
	};

	short m_Monster;
	unsigned char m_Master;
};

/// <summary>
/// Spawn Monster at Position
/// </summary>
class Action37 : public Object
{
	void Load( FILE* a_File )
	{
		fread( &m_Monster, sizeof( m_Monster ), 1, a_File );
		fread( &m_Position, sizeof( m_Position ) + 1, 1, a_File );
		fread( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fread( &m_Master, sizeof( m_Master ) + 3, 1, a_File );
	};

	void Save( FILE* a_File )
	{
		fwrite( &m_Monster, sizeof( m_Monster ), 1, a_File );
		fwrite( &m_Position, sizeof( m_Position ) + 1, 1, a_File );
		fwrite( &m_Distance, sizeof( m_Distance ), 1, a_File );
		fwrite( &m_Master, sizeof( m_Master ) + 3, 1, a_File );
	};
	
	short m_Monster;
	unsigned char m_Position;
	int m_Distance;
	unsigned char m_Master;
};
#pragma endregion Actions

class Action
{
public:
	Action();
	~Action();	
	void Load( FILE* a_File );
	void Save( FILE* a_File );

	int m_Size;
	int m_Command;
	Object* m_Value;

};

class Block
{
public:
	Block();
	~Block();
	void Load( FILE* a_File );
	void Save( FILE* a_File );

	//Variables
	char m_BlockName[32];
	int m_ConditionCount;
	LinkedList< Condition >* m_Conditions;
	Iterator< Condition >* m_ConditionsIt;

	int m_ActionCount;	
	LinkedList< Action >* m_Actions;
	Iterator< Action >* m_ActionsIt;
};

class Trigger
{
public:
	Trigger();
	~Trigger();
	void Load( FILE* a_File );
	void Save( FILE* a_File );

	//Variables
	char m_TriggerName[32];
	int m_BlockCount;
	LinkedList< Block >* m_Blocks;
	Iterator< Block >* m_BlocksIt;
};

class AIP
{
public:
	AIP(void);
	~AIP(void);

	void Load( char* a_FilePath );
	void Save( char* a_FilePath );

private:
	int m_TriggerCount;
	int m_IdleCheck;
	int m_DamageCheck;
	char* m_TitleOne;
	char m_Title[255];
	unsigned int m_TitleLength;

	LinkedList< Trigger >* m_Triggers;
	Iterator< Trigger >* m_TriggersIt;

	FileHandler* m_Handler;

};

